import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ElderBasicVO, ElderBasicForm, ElderBasicQuery } from '@/api/nursing/elder/types';

/**
 * 查询老人列表
 * @param query
 * @returns {*}
 */
export const listElder = (query?: ElderBasicQuery): AxiosPromise<TableDataInfo<ElderBasicVO>> => {
  return request({
    url: '/nursing/elder/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询老人详细信息
 * @param elderId
 */
export const getElder = (elderId: string | number): AxiosPromise<ElderBasicVO> => {
  return request({
    url: '/nursing/elder/' + elderId,
    method: 'get'
  });
};

/**
 * 新增老人
 * @param data
 */
export const addElder = (data: ElderBasicForm) => {
  return request({
    url: '/nursing/elder',
    method: 'post',
    data: data
  });
};

/**
 * 修改老人
 * @param data
 */
export const updateElder = (data: ElderBasicForm) => {
  return request({
    url: '/nursing/elder',
    method: 'put',
    data: data
  });
};

/**
 * 删除老人
 * @param elderId
 */
export const delElder = (elderId: string | number | Array<string | number>) => {
  return request({
    url: '/nursing/elder/' + elderId,
    method: 'delete'
  });
};
